﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FanPages.Server.Services.Contracts.Dto;
using FanPages.Common;
using FanPages.Model;

namespace FanPages.Client.Core.Transformers
{
    public class FanItemTransformer : ITransformer<FanItem, FanItemDto>
    {
        public FanItemDto ToDto(FanItem clientEntity)
        {
            FanItemDto dto = new FanItemDto()
            {
                Code = clientEntity.Code,
                Description = clientEntity.Description,
                Name = clientEntity.Name,
                Id = clientEntity.Id,
                Image = clientEntity.Image
            };
            return dto;
        }

        public FanItem ToClient(FanItemDto dtoEntity)
        {
            FanItem item = new FanItem()
            {
                Name = dtoEntity.Name,
                Description = dtoEntity.Description,
                Code = dtoEntity.Code,
                Id = dtoEntity.Id,
                Image = dtoEntity.Image
            };
            return item;
        }


        public List<FanItemDto> ToListDto(List<FanItem> list)
        {
            var result = new List<FanItemDto>();
            list.ForEach(x =>
            {
                result.Add(ToDto(x));
            });
            return result;
        }

        public List<FanItem> ToListEntity(List<FanItemDto> list)
        {
            var result = new List<FanItem>();
            list.ForEach(x =>
            {
                result.Add(ToClient(x));
            });
            return result;
        }
    }
}
